package com.thread.exception.demo2;

import java.util.concurrent.ThreadFactory;

//通过编写定制的ThreadFactory可以定制由Executor创建的线程的属性
public class HandlerThreadFactory implements ThreadFactory {

	@Override
	public Thread newThread(Runnable r) {
		System.out.println(this + "创建新线程");
		Thread t = new Thread(r);
		System.out.println("创建完成：" + t);
		t.setUncaughtExceptionHandler(new MyUncaughtExceptionHandler());
		System.out.println("eh=" + t.getUncaughtExceptionHandler());
		return t;
	}

}
